﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LithuanianOutLoud
{
    public partial class DialogBox : Form
    {
        public int selectedValue = -1;
        Form1 ParentF;

        public DialogBox(Form1 parentForm)
        {
            InitializeComponent();
            ParentF = parentForm;
            label2.Text = "[1, " + ParentF.feed.LOOMediaItems.Count + "]";
            this.ActiveControl = textBox1;
        }

        private void DialogBox_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Check that selection is within range
            
            try 
            { 
                this.selectedValue = Int32.Parse(textBox1.Text);
                if (this.selectedValue >= 1 && this.selectedValue <= ParentF.feed.LOOMediaItems.Count)
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Input a value between 1 and " + ParentF.feed.LOOMediaItems.Count);
                }
            }
            catch (FormatException)
            {
                string message = "Please input a value between 1 and " + ParentF.feed.LOOMediaItems.Count;
                MessageBox.Show(message, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                  
            }
            catch (OverflowException)
            {
                string message = "Please input a value between 1 and " + ParentF.feed.LOOMediaItems.Count;
                MessageBox.Show(message, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            

        }

        private void button2_Click(object sender, EventArgs e)
        {
            // Cancel
            this.Close();
        }


    }
}
